/*
 * define the joky's config, like color and style and so on
 */

#ifndef CONFIG_H
#define CONFIG_H

/*================================================*/
/* include */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
#include <sys/utsname.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdarg.h>
#include <time.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <libgen.h>
#include <assert.h>

/*================================================*/
/* basic color */
#define BLACK       "\e[0;30m"
#define RED         "\e[0;31m"
#define GREEN       "\e[0;32m"
#define YELLOW      "\e[0;33m"
#define BLUE        "\e[0;34m"
#define MAGENTA     "\e[0;35m"
#define CYAN        "\e[0;36m"
#define WHITE       "\e[0;37m"

/* highlight color */
#define BLACK_HL    "\e[1;30m"
#define RED_HL      "\e[1;31m"
#define GREEN_HL    "\e[1;32m"
#define YELLOW_HL   "\e[1;33m"
#define BLUE_HL     "\e[1;34m"
#define MAGENTA_HL  "\e[1;35m"
#define CYAN_HL     "\e[1;36m"
#define WHITE_HL    "\e[1;37m"

/* background color */
#define BLACK_BG    "\e[40m"
#define RED_BG      "\e[41m"
#define GREEN_BG    "\e[42m"
#define YELLOW_BG   "\e[43m"
#define BLUE_BG     "\e[44m"
#define MAGENTA_BG  "\e[45m"
#define CYAN_BG     "\e[46m"
#define WHITE_BG    "\e[47m"

/* text style*/
#define BOLD        "\e[1m"
#define UNDERLINE   "\e[4m"
#define REVERSE     "\e[7m"
#define HIDDEN      "\e[8m"

/* default */
#define RESET       "\e[0m"

/* file types */
#define T_DIR 	1 	// directory file
#define T_CHR 	2 	// char device file
#define T_BLK 	3 	// block device file
#define T_LNK 	4 	// link file
#define T_REG 	5 	// regular file
#define T_FIFO 	6 	// pipe file
#define T_SOCK 	7 	// socket file
#define T_UNKW 	8 	// unknown file

/* file display style */
// the style for displaying type
#define DIR_STYLE 	CYAN_HL 	// directory file
#define CHR_STYLE 	RED_HL 		// char device file
#define BLK_STYLE 	MAGENTA_HL 	// block device file
#define LNK_STYLE 	BLUE_HL 	// link file
#define REG_STYLE 	WHITE_HL 	// regular file
#define FIFO_STYLE 	YELLOW_HL 	// pipe file
#define SOCK_STYLE 	GREEN_HL 	// socket file
#define UNKW_STYLE 	BLACK_HL 	// unknown file
// the style for displaying concrete file
#define DIR_C_STYLE 	CYAN 	// directory file
#define CHR_C_STYLE 	RED 	// char device file
#define BLK_C_STYLE 	MAGENTA // block device file
#define LNK_C_STYLE 	BLUE 	// link file
#define REG_C_STYLE 	WHITE 	// regular file
#define FIFO_C_STYLE 	YELLOW 	// pipe file
#define SOCK_C_STYLE 	GREEN 	// socket file
#define UNKW_C_STYLE 	BLACK 	// unknown file

/*================================================*/
#define SYM 		    "$"
#define SYM_STYLE 	    CYAN 	

#define PROMPT 			"JOKY@"
#define PROMPT_STYLE 	(REVERSE BOLD)

#define CUR_DIR_STYLE 	(GREEN_HL)

#define JOKY_VERSION 	"0.2"

#define JOKY_HOME 		"/home/winterz/Project/joky/"

/*================================================*/
/* limit */
#define CMD_TOKEN_INIT_SIZE  	10 		/* just allow 10 args at begin */
#define CMD_TOKEN_MAX_SIZE  	20 		/* just allow 20 args maximally */
#define CMD_LINE_BUFSIZE 		300 	/* just allow 100 bytes for cmd-line input */
#define FILEPATH_SIZE 			1024 	/* file path should be lower than 256bytes */
#define FILENAME_SIZE 			256 	/* file name's size */
#define MAX_ENTRIES 			256 	/* the max number of dir entries at once */
#define BUF_SIZE 				1024 	/* I/O buffer size */

/* history command */
#define CMD_HST_FILE 	        (JOKY_HOME ".history")
#define CMD_HST_COUNT 	        200

/*================================================*/
typedef struct direntry_t {
	char name[FILENAME_SIZE];
	int file_type;
} direntry_t;

/*================================================*/
char* cur_dir();  		// get the current directory
char* get_prompt();  	// get the prompt
direntry_t *get_list_files(const char *diretory); 	// get all files under directory 
void print_list_files(direntry_t *de, int list_hidden, const char *start); 	// print the files with options
int is_dir(const char *path); 	// judge that path is a directory

/*================================================*/
extern struct termios orig_termios; 	// terminal's attribute

#endif
